<template>
    <h1>登录页面</h1>

    <table class="table table-bordered">
        <tr>
            <td>用户名:</td>
            <td>
                <input type="text" v-model="Name" />
            </td>
        </tr>

        <tr>
            <td>密码:</td>
            <td>
                <input type="password" v-model="Pwd" />
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="登录" @click="login" />
            </td>
        </tr>

    </table>

</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

const Name = ref("");
const Pwd = ref("");

const login = () => {

    if(Name.value == "" ){
        alert("用户名不能为空");
        return;
    }

    if(Pwd.value == "" ){
        alert("密码不能为空");
        return;
    }

    if (Name.value == "Admin123" && Pwd.value == "Admin123") {
        router.push({
            name:'LoginCg',
            params:{
                Name:Name.value,
                Pwd:Pwd.value
            }
        }) //Name  Pwd
    } else {
        alert("用户名或密码错误");
    }
}

</script>
